package com.jxwifi.cloud.quickclean.adapter;

import android.content.Intent;
import android.support.annotation.LayoutRes;
import android.support.annotation.NonNull;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jxwifi.cloud.quickclean.R;
import com.jxwifi.cloud.quickclean.app.StateUtils;
import com.jxwifi.cloud.quickclean.bean.OrderBean;
import com.jxwifi.cloud.quickclean.bean.ShopOrderDetailsBean;
import com.jxwifi.cloud.quickclean.toolkit.TKDetailsActivity;

public class KtOrderFgAdapter extends BaseQuickAdapter<ShopOrderDetailsBean, BaseViewHolder> {
    private TkDetailsAdapter mAdapter;
    public KtOrderFgAdapter(@LayoutRes int layoutResId) {
        super(layoutResId, null);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper,final ShopOrderDetailsBean item) {
        helper.setText(R.id.tv_shop_order_list_starts, StateUtils.KtOrderStarts(item.getOrder().getShopProductTravalling().getStatus()));
        helper.setText(R.id.tv_shop_order_list_number,"共"+item.getOrderContain().size()+"种商品 合计：\u00A5"+item.getOrder().getDiscountSumVal());
        RecyclerView mRvList=helper.getView(R.id.rv_shop_order_list_item);
        mRvList.setLayoutManager(new LinearLayoutManager(mContext));
        mRvList.setAdapter(mAdapter = new TkDetailsAdapter(R.layout.list_details_kit_item, item.getOrderContain()));
        mAdapter.openLoadAnimation();
        mAdapter.openLoadAnimation(BaseQuickAdapter.FOOTER_VIEW);
        mAdapter.setOnItemChildClickListener(new OnItemChildClickListener() {
            @Override
            public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
                switch (view.getId()){
                    case R.id.rel_details_kit_items:
                        Intent intent=new Intent();
                        intent.setClass(mContext, TKDetailsActivity.class);
                        intent.putExtra("tk_code",item.getOrder().getOrderCode());
                        mContext.startActivity(intent);
                        break;
                }
            }
        });

        helper.addOnClickListener(R.id.rel_list_my_order);
    }
}
